home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / mod2tutb.zip / SIMPLIN.MOD < prev    next >
Text File  |  1989-01-18  |  2KB  |  75 lines

  1.                                          (* Chapter 8 - Program 2 *)
  2. MODULE SimplIn;
  3.  
  4. FROM InOut IMPORT WriteString, WriteCard, WriteLn, Write,
  5.                   ReadString, ReadCard, Read, EOL;
  6.  
  7. VAR Count, Number : CARDINAL;
  8.     List          : ARRAY[1..6] OF CARDINAL;
  9.     StringOfData  : ARRAY[1..80] OF CHAR;
  10.     Alpha         : CHAR;
  11.  
  12. BEGIN
  13.                           (* Example of reading in a word at a time *)
  14.    WriteString("Input three words of information.");
  15.    WriteLn;
  16.    FOR Count := 1 TO 3 DO                        (* Read 3 words in *)
  17.       ReadString(StringOfData);
  18.       WriteString("---->");
  19.       WriteString(StringOfData);
  20.       WriteLn;
  21.    END;
  22.                                     (* Example of character reading *)
  23.    WriteLn;
  24.    WriteString("Input 50 characters.");
  25.    WriteLn;
  26.    FOR Count := 1 TO 50 DO
  27.       Read(Alpha);
  28.       Write(Alpha);
  29.    END;
  30.    WriteLn;
  31.                          (* Example of reading in a line at a time. *)
  32.    WriteLn;
  33.    WriteString("Input three lines of information.");
  34.    WriteLn;
  35.    FOR Count := 1 TO 3 DO                      (* count three lines *)
  36.       Number := 1;
  37.       REPEAT                (* repeat until an end-of-line is found *)
  38.          Read(Alpha);
  39.          Write(Alpha);
  40.          IF Alpha # EOL THEN
  41.             StringOfData[Number] := Alpha;
  42.             Number := Number + 1;
  43.          END;
  44.       UNTIL Alpha = EOL;
  45.       StringOfData[Number] := 0C;        (* End of string indicator *)
  46.       WriteString("---->");
  47.       WriteString(StringOfData);
  48.       WriteLn;
  49.    END;
  50.                           (* Example of reading CARDINAL numbers in *)
  51.    WriteLn;
  52.    WriteString("Enter 6 CARDINAL numbers.");
  53.    WriteLn;
  54.    FOR Count := 1 TO 6 DO
  55.       ReadCard(List[Count]);
  56.       WriteLn;                (* New line for separation of numbers *)
  57.    END;
  58.    WriteLn;
  59.    FOR Count := 1 TO 6 DO             (* Now, write the numbers out *)
  60.       WriteCard(List[Count],8);
  61.    END;
  62.    WriteLn;
  63.  
  64. END SimplIn.
  65.  
  66.  
  67.  
  68.  
  69. (* Result of execution
  70.  
  71. (The output depends on what is entered at the keyboard.)
  72.  
  73. *)
  74.  
  75.